#include "displaydatawindow.h"
#include "ui_displaydatawindow.h"

DisplayDataWindow::DisplayDataWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DisplayDataWindow)
{
    ui->setupUi(this);
    tableWidget = ui->tableWidget;
    tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
}

DisplayDataWindow::~DisplayDataWindow()
{
    delete ui;
}

void DisplayDataWindow::displayResultsByEvent(const QList<QList<QString>>& data)
{
    tableWidget->setRowCount(data.size());
    tableWidget->setColumnCount(3); // 设置列数为3
    QStringList headers;
    headers << "学院/项目" << "学院/项目名称" << "对应编号";
    tableWidget->setHorizontalHeaderLabels(headers);

    for (int i = 0; i < data.size(); ++i) {
        for (int j = 0; j < data[i].size(); ++j) {
            tableWidget->setItem(i, j, new QTableWidgetItem(data[i][j]));
        }
    }
}

void DisplayDataWindow::displayData(const QList<QList<QString>>& data)
{
    tableWidget->setRowCount(data.size());
    tableWidget->setColumnCount(3); // 设置列数为3
    QStringList headers;
    headers << "学院/项目" << "学院/项目名称" << "对应编号";
    tableWidget->setHorizontalHeaderLabels(headers);

    for (int i = 0; i < data.size(); ++i) {
        for (int j = 0; j < data[i].size(); ++j) {
            tableWidget->setItem(i, j, new QTableWidgetItem(data[i][j]));
        }
    }
}
